home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 24
/
Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso
/
Aminet
/
dev
/
lang
/
PPCsmalltalk.lha
/
PPCSmallTalk
/
prelude
/
semaphore.st
< prev
next >
Wrap
Text File
|
1986-10-19
|
530b
|
25 lines
Class Semaphore :List
| excessSignals |
[ new
excessSignals <- 0
| new: aNumber
excessSignals <- aNumber
| signal
<primitive 148>. "start atomic action"
(self isEmpty)
ifTrue: [excessSignals <- excessSignals + 1]
ifFalse: [self removeFirst unblock].
<primitive 149> "end atomic action"
| wait
<primitive 148>. "start atomic actions"
(excessSignals = 0)
ifTrue: [self addLast: selfProcess.
selfProcess block]
ifFalse: [excessSignals <- excessSignals - 1].
<primitive 149> "end atomic actions"
]